﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Project1
{

    /// <summary>
    /// This is the data structure for a stop.
    /// </summary>
    struct Stop : IComparable
    {
        /// <summary>
        /// Address of the stop.
        /// </summary>
        string address;

        /// <summary>
        /// ID for the stop.
        /// </summary>
        int stopID;

        /// <summary>
        /// Creates a HashSet of students at a stop.
        /// </summary>
        HashSet<Student> students;

        /// <summary>
        /// Get or set the stopID of a stop.
        /// </summary>
        public int StopID
        {
            get { return stopID; }
            set { stopID = value; }
        }

        /// <summary>
        /// Get or set the address of a stop.
        /// </summary>
        public string Address
        {
            get { return address; }
            set { address = value; }
        }

        /// <summary>
        /// Compares this stop's ID to another stop's ID.
        /// </summary>
        public int CompareTo(object obj)
        {
            try
            {
                Stop otherStop = (Stop)obj;
                return this.StopID.CompareTo(otherStop.StopID);
            }
            catch (Exception e)
            {
                throw new ArgumentException("Object is not a stop.");
            }
        }

        
    }

    /// <summary>
    /// This is a data structure for a school.
    /// </summary>
    struct School
    {
        /// <summary>
        /// Value of student size used for bus capacity.
        /// </summary>
        private double studentSize;

        /// <summary>
        /// Address of the school.
        /// </summary>
        private string address;

        /// <summary>
        /// HashSet of the stops within the boundary of the school.
        /// </summary>
        private HashSet<Stop> boundary;

        /// <summary>
        /// Creates a new school.
        /// </summary>
        public School(double size, string addr)
        {
            studentSize = size;
            address = addr;
            boundary = new HashSet<Stop>();
        }

        /// <summary>
        /// Adds a stop to the school's boundary.
        /// </summary>
        public void addStopToBoundary(Stop stop)
        {
            boundary.Add(stop);
        }

        /// <summary>
        /// Adds a stop to the given school's boundary.
        /// </summary>
        public static void AddStopToSchoolsBoundary(School sch, Stop stop)
        {
            sch.addStopToBoundary(stop);
        }

        /// <summary>
        /// Adds many stops to the school's boundary.
        /// </summary>
        public void addStopsToBoundary(IEnumerable<Stop> stops)
        {
            foreach (Stop stop in stops)
            {
                this.addStopToBoundary(stop);
            }
        }

        /// <summary>
        /// Adds many stops to the given school's boundary.
        /// </summary>
        public static void AddStopsToSchoolBoudary(School sch, IEnumerable<Stops> stops)
        {
            sch.addStopsToBoundary(stops);
            
        }

        /// <summary>
        /// Remove a stop from a school's boundary.
        /// </summary>
        public void removeStopFromBoundary(Stop stop)
        {
            boundary.Remove(stop);
        }

        /// <summary>
        /// Remove a stop from a given school's boundary.
        /// </summary>
        public static void RemoveStopFromSchoolBoundary(School sch, Stop stop)
        {
            sch.removeStopFromBoundary(stop);
        }

        /// <summary>
        /// Remove stops from a boundary.
        /// </summary>
        public void removeStopsFromBoundary(IEnumerable<Stop> stops)
        {
            foreach (Stop stop in stops)
            {
                this.removeStopFromBoundary(stop);
            }
        }

        /// <summary>
        /// Remove stops from a given school's boundary.
        /// </summary>
        public static void RemoveStopsFromSchoolBoundary(School sch, IEnumerable<Stop> stops)
        {
            sch.removeStopsFromBoundary(stops);
        }
    }

    /// <summary>
    /// This is the data structure for a student.
    /// </summary>
    struct Student : IComparable
    {
        private int studentID;
        private string address;
        private School school;

        /// <summary>
        /// Creates a new student with an ID, address, and school.
        /// </summary>
        public Student(int ID, String addr, School sch)
        {
            studentID = ID;
            address = addr;
            school = sch;
        }

        /// <summary>
        /// Get or set the student's studentID.
        /// </summary>
        public int StudentID
        {
            get { return studentID; }
            set { studentID = value; }
        }

        /// <summary>
        /// Get or set the student' address.
        /// </summary>
        public string Address
        {
            get { return address; }
            set { address = value; }
        }

        /// <summary>
        /// Get or set the student's school.
        /// </summary>
        public School School
        {
            get { return school; }
            set { school = value; }
        }

        /// <summary>
        /// Compare's the student's studentID to another student's studentID.
        /// </summary>
        public int CompareTo(object obj)
        {
            try
            {
                Student otherStudent = (Student)obj;
                return this.StudentID.CompareTo(otherStudent.StudentID);
            }
            catch (Exception e)
            {
                throw new ArgumentException("Object is not a student.");
            }
        }
    }
}
